package com.banshou.installs.ui.fragment;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.banshou.installs.R;
import com.banshou.installs.constant.BaseApplication;
import com.banshou.installs.databinding.SelfBinding;
import com.banshou.installs.ui.activity.InstallHisActivity;
import com.banshou.installs.ui.activity.SetActivity;
import com.banshou.installs.ui.activity.StaffManagerActivity;
import com.banshou.installs.utils.SharePreUtil;

/**
 * Created by cjq on 2017/12/29.
 * Email: stoic_yb@139.com
 * features: 个人中心
 */

public class SelfFragment extends BaseFragment implements View.OnClickListener{

    private SelfBinding mBinding;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        mBinding = DataBindingUtil.inflate(inflater, R.layout.self, container, false);
        initView();
        return mBinding.getRoot();
    }

    private void initView() {
        mBinding.selfRl2.setOnClickListener(this);
        mBinding.selfRl3.setOnClickListener(this);
        mBinding.selfRl4.setOnClickListener(this);
        if(SharePreUtil.getPower(BaseApplication.getContext(),4)==4){
            mBinding.selfRl3.setVisibility(View.GONE);
        }else{
            mBinding.selfRl3.setVisibility(View.VISIBLE);
        }
        mBinding.selfName.setText(SharePreUtil.getName(getActivity(),"NULL"));
        mBinding.selfCompany.setText(SharePreUtil.getCompanyName(getActivity(),"NULL"));
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            //历史安装
            case R.id.self_rl2:
                Intent intent = new Intent(getActivity(), InstallHisActivity.class);
                startActivity(intent);
                break;
            //员工管理
            case R.id.self_rl3:
                Intent staffIntent = new Intent(getActivity(),StaffManagerActivity.class);
                startActivity(staffIntent);
                break;
            //设置
            case R.id.self_rl4:
                Intent setIntent = new Intent(getActivity(), SetActivity.class);
                startActivity(setIntent);
                break;
        }
    }

}
